<template>
    <div class="card">
        <div class="left">
            <div class="list-content">
                <div class="list" v-for="item in list" @click="toUrl(item)">
                    <div class="title">{{item.name}}</div>
                    <div class="font">
                        <span>共{{item.total}} | 已掌握</span>
                        <span style="color: #268CFF;">{{item.master}}</span>
                        <span> | 未掌握</span>
                        <span style="color: #FF9521;">{{item.not}}</span>
                    </div>
                    <div class="progress">
                        <el-progress :percentage="item.master==0?0:((item.master/item.total)*100).toFixed(2)"></el-progress>
                    </div>
                    <div class="arrow">
                        <i class="el-icon-arrow-right" style="color:#9da3b2"></i>
                    </div>
                </div>
            </div>
        </div>
        <div class="right">
            <div class="list" style="margin:0" @click="toUrl(learn)">
                <div class="tip">上次练习</div>
                <div class="title">{{learn.name}}</div>
                <div class="font">
                    <span>共{{learn.total}} | 已掌握</span>
                    <span style="color: #268CFF;">{{learn.master}}</span>
                    <span> | 未掌握</span>
                    <span style="color: #FF9521;">{{learn.not}}</span>
                </div>
                <div class="progress">
                    <el-progress :percentage="learn.master==0?0:((learn.master/learn.total)*100).toFixed(2)"></el-progress>
                </div>
                <div class="arrow">
                    <i class="el-icon-arrow-right" style="color:#9da3b2"></i>
                </div>
             </div>
        </div>
    </div>
</template>
<script>
export default {
    data(){
        return{
            learn:{
                name:'刑法学',
                total:255,
                master:0,
                not:0,
                param:'xf'
            },
            list:[{
                name:'刑法学',
                total:255,
                master:0,
                not:0,
                param:'xf'
            },{
                name:'民法学',
                total:255,
                master:0,
                not:0,
                param:'mf'
            },{
                name:'法理学',
                total:180,
                master:0,
                not:0,
                param:'fl'
            },{
                name:'中国宪法学',
                total:160,
                master:0,
                not:0,
                param:'zgxf'
            },{
                name:'中国法制史',
                total:135,
                master:0,
                not:0,
                param:'fzs'
            }]
        }
    },
    mounted(){
        let user = this.$gl('nowUser')
        this.list.forEach(item=>{
            item.master = user[item.param].grasp.length
            item.not = user[item.param].ungrasp.length
        })
        let learn= this.list.filter(item=>{
           return item.param == user.last 
        })
        learn.length?this.learn = learn[0]:this.learn = this.list[0]
    },
    methods:{
        toUrl(item){
            this.$router.push({
                name:'recite',
                params:{
                    type:item.param
                }
            })
        }
    }
}
</script>
<style lang="less" scoped>
.card{
    width: 100%;
    height: 100%;
    overflow: auto;
    display: flex;
    justify-content: space-between;
    .right{
        width: 380px;
    }
    .left{
        width: calc(100% - 400px);
        background-color: #fff;
        height: 100%;
        padding: 5px;
        overflow: auto;
        .list-content{
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-start;

        }
    }
    .list{
        width: 380px;
        min-height: 112px;
        margin-bottom: 20px;
        padding: 20px;
        margin: 10px;
        background: #ffffff;
        border: 1px solid #eeeeee;
        border-radius: 5px;
        cursor: pointer;
        position: relative;
        box-shadow: 0px 7px 8px 0px rgb(0 0 0 / 3%);
        .tip{
                width: 68px;
            height: 20px;
            opacity: 1;
            background: #e9f5ff;
            border: 1px solid #67b7ff;
            border-radius: 3px;
            font-size: 12px;
            /* font-weight: 400; */
            text-align: center;
            color: #268cff;
            line-height: 20px;
            margin-bottom: 13px;

        }
        .title{
            height: 22px;
            opacity: 1;
            font-size: 16px;
            font-weight: 500;
            text-align: left;
            color: #41485d;
            line-height: 22px;
            width: 250px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
        .font{
                margin-top: 10px;
                font-size: 12px;
                /* font-weight: 400; */
                text-align: left;
                color: #9da3b2;
                line-height: 16px;
        }
        .progress{
            width: 200px;
            margin-top: 5px;
        }
        .arrow{
            position: absolute;
            right: 10px;
            bottom: 40px;
        }
    }


    
}
</style>